package cn.zorbus.jpa;

import cn.hutool.core.util.IdUtil;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.id.IdentifierGenerator;

import java.io.Serial;

/**
 * create in 2024/11/8 01:34
 *
 * @author shishaodong
 * @version 0.0.1
 */
public class SnowflakeIdGenerator implements IdentifierGenerator {

    @Serial
    private static final long serialVersionUID = -4927405259883055072L;

    @Override
    public Object generate(SharedSessionContractImplementor session, Object object) {
        return IdUtil.getSnowflake().nextId();
    }
}
